#include <bits/stdc++.h>
using namespace std;

class Solution {
public:
    int numberOfBoomerangs(vector<vector<int>>& points) {
        int size = points.size();
        if(size < 3) return 0;

        int res = 0;
        for(int i = 0; i < size; ++i){
            unordered_map<int, int> dict;
            for(int j = 0; j < size; ++j){
                int dis = pow(points[i][0] - points[j][0], 2) + pow(points[i][1] - points[j][1], 2);
                ++dict[dis];
            }
            for(auto e: dict){
                if(e.second >= 2)
                    res += (e.second * (e.second - 1));
            }
        }
        return res;
    }
};



int main(int argc, char const *argv[])
{
    Solution sol;

    // vector<vector<int>> points = {{0,0},{1,0},{2,0}};
    vector<vector<int>> points = {{1,1},{2,2},{3,3}};
    cout << sol.numberOfBoomerangs(points) << endl;

    return 0;
}
